package com.order.demo.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;


/**
 * @Description ordercontroller
 * @Author xiao  xun
 * @Date 2025-09-10
 */
@RestController
@RequestMapping("/order")
public class ordercontroller {

    private static final Logger logger = LoggerFactory.getLogger(ordercontroller.class);


    // 添加一个简单的订单查询接口来演示日志记录
    @GetMapping("/info")
    public HashMap<String, Object> listOrders() {
        logger.info("Fetching order list");
        HashMap<String, Object> result = new HashMap<>();
        try {
            int i = 1 / 0;

            // 模拟查询订单列表
            result.put("code", 200);
            result.put("message", "Success");
            result.put("data", "Order list data");
            logger.info("Order list fetched successfully"+i);
        } catch (Exception e) {
            logger.error("Failed to fetch order list", e);
            result.put("code", 500);
            result.put("message", "Failed to fetch orders");
        }
        return result;
    }
}
